<div class="events index">
   	<h2>
   	<?php 
   		if ($review_type == 'read') 
   			echo 'reviews for "' . $event['Event']['event_name'] . '"';
   		else if ($review_type =='write')
   			echo 'writes a review for "' . $event['Event']['event_name'] . '"';
   	?>
   	</h2>
    <table>
        <tr>
            <td class="actions">
                <?php echo $this->Html->link(__('Upcoming', true), array('controller' => 'events', 'action' => 'index','upcoming')); ?>
                <?php echo $this->Html->link(__('Past', true), array('controller' => 'events', 'action' => 'index','past')); ?>
            </td>
        </tr>
    </table>

  
 	<?php 
  	if ($review_type == 'read') {
  		if ($reviews) {
  			foreach ($reviews as $review) { ?>
  				<div class="review_listing">
            	<div class="review_listing_left">
            		<?php 
            		$image = '';
					if (file_exists('img/profile/user/' . $review['User']['id'] . '.jpg'))
						$image = 'profile/user/' . $review['User']['id'] . '.jpg';
					else
						$image = '/img/default_user.jpg';
					echo $this->Html->image($image, array('width'=>100));
            		?>
            	</div>
            	<div class="review_listing_right">
            		<?php
            		echo 'rating: ' . $review['AttendEvent']['rating'] . ' out of 5, ' . $review['AttendEvent']['feedback_time'] . "<p>";
            		echo 'by ' . $review['User']['first_name'] . ' ' . $review['User']['last_name'] . "<p>"; 
            		echo $review['AttendEvent']['feedback'];
            		?>
            	</div>
            	</div>
  		<?php }  		
  		} else {
  			echo "<h3>";
  			echo 'There is no review for this event';
  			echo "</h3>";
  		}
  		// if the user is an attendance and has not given review, ..... option to write 
  	} else if ($review_type == 'write') {
  		echo $this->Form->create('Event', array('action'=>'reviews/write/'.$event['Event']['id'],'enctype' => 'multipart/form-data'));
  		$options = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5');
  		echo $this->Form->input('rating', array(
  									'type' => 'select',
  									'options' => array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5'),
  									'label' => 'rating',
 									'empty' => ''));
    	echo $form->input('feedback', array('type'=>'textarea'));
    	echo $form->end('Submit Review');
  	}
  ?>
  	
    
</div>

